{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"0a0527f4166a41bcb48d9e2b7dbd910f\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_0a0527f4166a41bcb48d9e2b7dbd910f = echarts.init(\n",
       "                    document.getElementById('0a0527f4166a41bcb48d9e2b7dbd910f'), 'white', {renderer: 'canvas'});\n",
       "                var option_0a0527f4166a41bcb48d9e2b7dbd910f = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u7f8e\\u56fd\",\n",
       "            \"data\": [\n",
       "                6938591.68,\n",
       "                6787419.03,\n",
       "                6545969.33,\n",
       "                6710218.18,\n",
       "                6759995.63,\n",
       "                6623775.48,\n",
       "                6492267.43,\n",
       "                6456718.19\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u6b27\\u6d32\",\n",
       "            \"data\": [\n",
       "                4783627.79,\n",
       "                4626382.21,\n",
       "                4563064.71,\n",
       "                4468920.46,\n",
       "                4297635.77,\n",
       "                4327313.2,\n",
       "                4303391.87,\n",
       "                4323163.15\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u7f8e\\u56fd\",\n",
       "                \"\\u6b27\\u6d32\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u7f8e\\u56fd\": true,\n",
       "                \"\\u6b27\\u6d32\": true\n",
       "            },\n",
       "            \"show\": true\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2010\",\n",
       "                \"2011\",\n",
       "                \"2012\",\n",
       "                \"2013\",\n",
       "                \"2014\",\n",
       "                \"2015\",\n",
       "                \"2016\",\n",
       "                \"2017\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e8c\\u6c27\\u5316\\u78b3\\u6392\\u653e\\u91cf\",\n",
       "            \"subtext\": \"\\u6b27\\u7f8e\\u5bf9\\u6bd4\"\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_0a0527f4166a41bcb48d9e2b7dbd910f.setOption(option_0a0527f4166a41bcb48d9e2b7dbd910f);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x112835668>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import csv, os\n",
    "data = pd.read_csv('oecd_carbon_emissions_data.csv',index_col='Country') \n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Bar\n",
    "美国 = list(data.loc['United States'].values)[-8:]\n",
    "欧洲 = list(data.loc['European Union (28 countries)'].values)[-8:]\n",
    "def bar_base() -> Bar:\n",
    "    h = (\n",
    "        Bar()\n",
    "        .add_xaxis(([\"2010\", \"2011\", \"2012\", \"2013\", \"2014\", \"2015\",\"2016\",\"2017\"]))\n",
    "        .add_yaxis(\"美国\", 美国)\n",
    "        .add_yaxis(\"欧洲\", 欧洲)\n",
    "        .set_global_opts(title_opts=opts.TitleOpts(title=\"二氧化碳排放量\", subtitle=\"欧美对比\"))\n",
    "    )\n",
    "    return h\n",
    "b = bar_base()\n",
    "b.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
